//
//  HomeQustionInfoViewController.m
//  ZJControlsClass
//
//  Created by mac on 2024/11/16.
//

#import "HomeQustionInfoViewController.h"
#import "HomeQuestionSliderProgessView.h"
#import "HomeQuestionResultAlertView.h"
#import "HomeQuestionCompulsoryEndTestAlertView.h"
#import "HomeQuestionOverTestAlertView.h"
#import "HomeQuestionCompleteInfoViewController.h"


#import "HomeAvailableNetworking.h"
#import "HomeQuestionCollectionViewCell.h"

#import "HomeQuestionModel.h"
#import "HomeQuestionTestingSubmintModel.h"



@interface HomeQustionInfoViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>


@property (nonatomic,strong) UILabel * ansowerLabel;
@property (nonatomic,strong) UIProgressView * sliderProgress;
@property (nonatomic,strong) UIButton * lookInfoBtn;

@property (nonatomic,strong) UICollectionView * collectionView;
@property (nonatomic,strong) NSMutableArray * dataSource;
@property (nonatomic,strong) UIView * bottomView;

@property (nonatomic,strong) UIButton * overBtn;
@property (nonatomic,strong) UIButton * upBtn;
@property (nonatomic,strong) UIButton * nextBtn;

@property (nonatomic,assign) NSInteger totalNum;
@property (nonatomic,assign) NSInteger Index;


@property (nonatomic,strong) HomeProcessQuestionsNetworking * manager;
@property (nonatomic,strong) HomeProcessAnswerNetWorking * processAnwerManager;
@property (nonatomic,strong) HomeProcessSubmitNetWorking * submitManager;


@property (nonatomic,strong) UIView * kwindowView;
@property (nonatomic,strong) HomeQuestionSliderProgessView * progressView;
@property (nonatomic,strong) HomeQuestionResultAlertView * resultAlertView;
@property (nonatomic,strong) HomeQuestionCompulsoryEndTestAlertView * QZEndAlertView;
@property (nonatomic,strong) HomeQuestionOverTestAlertView * overTestAlertView;



@property (nonatomic,strong) HomeExamViolationCreateNetworking * createManager;


@end

@implementation HomeQustionInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = COLOR_RGB(50, 113, 237);
    
    self.kwindowView = [UIView new];
    self.kwindowView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    self.kwindowView.backgroundColor = [UIColor blackColor];
    self.kwindowView.alpha = 0;
    [kWindow addSubview:self.kwindowView];
    
    [self loadNet];
    self.Index = 1;
    [self setUpUI];
    
    // 监听当前界面是否退出后台
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
    
    
}

-(void)applicationDidEnterBackground{
    // 进入后台的逻辑
    NSLog(@"当前应用进入后台");
    
    [self.createManager dispatchTaskWithParam:@{@"examId":self.examId} completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
        if (responseObject && [responseObject[@"code"] intValue] == 200){
            [LUtilityTools showAlertWithTitle:@"温馨提示" message:@"当前应该退出后台" buttonAction:nil];
            return;
        }
    }];
    
}







-(void)setUpUI{
    
    [self.view addSubview:self.ansowerLabel];
    [self.view addSubview:self.lookInfoBtn];
    [self.view addSubview:self.sliderProgress];
    [self.view addSubview:self.collectionView];
    [self.view addSubview:self.bottomView];
    [self.bottomView addSubview:self.overBtn];
    [self.bottomView addSubview:self.upBtn];
    self.upBtn.hidden = YES; // 首次进入界面  隐藏
    [self.bottomView addSubview:self.nextBtn];
    
    [self.ansowerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(ALIGN_WIDTH_PT(12));
        make.top.equalTo(self.view).with.offset(ALIGN_HEIGHT_PT(20) + StatusBarHeight);
    }];
    
    [self.lookInfoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.ansowerLabel.mas_centerY);
        make.right.equalTo(self.view).with.offset(-ALIGN_WIDTH_PT(12));
        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(64), ALIGN_HEIGHT_PT(20))));
    }];
    
    [self.sliderProgress mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(ALIGN_WIDTH_PT(12));
        make.right.equalTo(self.view).with.offset(-ALIGN_WIDTH_PT(12));
        make.top.equalTo(self.ansowerLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(8));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(8)));
    }];
    
    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.sliderProgress.mas_bottom).with.offset(ALIGN_HEIGHT_PT(30));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(350)));
        make.left.right.equalTo(self.view);
    }];
    
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.view);
        make.top.equalTo(self.view).with.offset(SCREEN_HEIGHT - ALIGN_HEIGHT_PT(100));
    }];
    
    [self.overBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomView).with.offset(ALIGN_WIDTH_PT(12));
        make.top.equalTo(self.bottomView).with.offset(ALIGN_HEIGHT_PT(10));
        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(60), ALIGN_WIDTH_PT(60))));
    }];
    
    [self.upBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.overBtn.mas_centerY);
        make.left.equalTo(self.overBtn.mas_right).with.offset(ALIGN_WIDTH_PT(10));
        make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - ALIGN_WIDTH_PT(104)) / 2, ALIGN_HEIGHT_PT(44))));
    }];

    [self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.overBtn.mas_centerY);
        make.right.equalTo(self.bottomView).with.offset(-ALIGN_WIDTH_PT(12));
        make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - ALIGN_WIDTH_PT(104)), ALIGN_HEIGHT_PT(44))));
    }];
    
}


#pragma mark -- 网络请求
-(void)loadNet{
    
    [self.manager dispatchTaskWithParam:@{@"examId":self.examId} completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
        if (responseObject && [responseObject[@"code"] intValue] == 200){
            [self.dataSource addObjectsFromArray:[HomeQuestionModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"]]];
            self.totalNum = self.dataSource.count;
            self.ansowerLabel.text = [NSString stringWithFormat:@"答题进度%@/%@",@(self.Index),@(self.totalNum)];
            [self.collectionView reloadData];
        }else{
            [LUtilityTools showAlertWithTitle:@"温馨提示" message:responseObject[@"msg"] buttonAction:^{
                
            }];
        }
    }];
    
}


#pragma mark -- 点击事件
-(void)respondsTo_lookInfoBtn{
    
    self.kwindowView.alpha = 0.3;
    
    self.progressView = [HomeQuestionSliderProgessView new];
    self.progressView.frame = CGRectMake(0, SCREEN_HEIGHT - ALIGN_HEIGHT_PT(380), SCREEN_WIDTH, ALIGN_HEIGHT_PT(380));
    self.progressView.backgroundColor = [UIColor whiteColor];
    self.progressView.layer.cornerRadius = 16;
    self.progressView.layer.masksToBounds = YES;
    self.progressView.totalNum = 100;
    self.progressView.chooseNum = 50;
    [kWindow addSubview:self.progressView];
        
        __weak __typeof(self)weakSelf = self;
        self.progressView.block = ^{
            [weakSelf.progressView removeFromSuperview];
            weakSelf.kwindowView.alpha = 0;
        };

}

-(void)respondsTo_UpBtn{
    
    self.Index --;
    
    NSIndexPath * indexPath = [NSIndexPath indexPathForItem:self.Index - 1 inSection:0];
    [self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:(UICollectionViewScrollPositionLeft) animated:YES];
  
    [self.nextBtn setTitle:@"下一题" forState:(UIControlStateNormal)];
    if (self.Index == 1){
        
        self.upBtn.hidden = YES;
        self.nextBtn.hidden = NO;

        [self.upBtn mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.overBtn.mas_right).with.offset(ALIGN_WIDTH_PT(10));
            make.size.equalTo(@(CGSizeMake(0, ALIGN_HEIGHT_PT(44))));
        }];
        
        
        
        [self.nextBtn mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.bottomView).with.offset(-ALIGN_WIDTH_PT(12));
            make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - ALIGN_WIDTH_PT(104)) , ALIGN_HEIGHT_PT(44))));
        }];
        
        
    }else{
    
        self.upBtn.hidden = NO;
        self.nextBtn.hidden = NO;
        
        [self.upBtn mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.overBtn.mas_right).with.offset(ALIGN_WIDTH_PT(10));
            make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - ALIGN_WIDTH_PT(104)) / 2, ALIGN_HEIGHT_PT(44))));
        }];

        [self.nextBtn mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.bottomView).with.offset(-ALIGN_WIDTH_PT(12));
            make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - ALIGN_WIDTH_PT(104)) / 2, ALIGN_HEIGHT_PT(44))));
        }];
        
    }
    
    self.ansowerLabel.text = [NSString stringWithFormat:@"答题进度%@/%@",@(self.Index),@(self.totalNum)];
    float percentage = (float)self.Index / self.totalNum ;
    self.sliderProgress.progress = percentage;
    
    
    
}


-(void)respondsTo_nextBtn{
    
    if ([self.nextBtn.titleLabel.text isEqualToString:@"结束练习"]){
        
        // 网络请求 显示结果
        [LUtilityTools showAlertWithTitle:@"温馨提示" message:@"是否结束练习" cancelTitle:@"不了" buttonAction:^{
            
        } sureTitle:@"结束" ButtonAction:^{
            
            HomeQuestionModel * upModel = self.dataSource[self.Index - 1];
            
            NSDictionary * paramer = @{@"examId":self.examId,
                                          @"questionId":upModel.Id,
                                          @"myAnswer":upModel.myAnswer
            };
            [self.processAnwerManager dispatchTaskWithParam:paramer completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
                if (responseObject && [responseObject[@"code"] intValue] == 200){ // 一题一保成功后交卷
                    
                    
                    [self subMit];

                    
                }else{
                    [LUtilityTools showAlertWithTitle:@"温馨提示" message:responseObject[@"msg"] buttonAction:nil];
                    return;
                }
            }];
            
        }];
        
    }else{
        
        
        // 提交选择的数据
        
        HomeQuestionModel * upModel = self.dataSource[self.Index - 1];
        
        
        if (upModel.myAnswer.length <= 0){
            [MBProgressHUD showError:@"请答题"];
            return;
        }else{
            
            NSDictionary * paramer = @{@"examId":self.examId,
                                          @"questionId":upModel.Id,
                                          @"myAnswer":upModel.myAnswer
            };
            [self.processAnwerManager dispatchTaskWithParam:paramer completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
                if (responseObject && [responseObject[@"code"] intValue] == 200){
                    
                    NSString * str = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"handResult"]];
                    if ([str isEqualToString:@"0"] || [str isEqualToString:@"1"] || [str isEqualToString:@"<null>"]) {   // 处理结果: 0-未处理, 1-不计违规, 2-考卷作废, 3-结束考试 <null> 未违规
                        [self upAnswer];
                    }else if ([str isEqualToString:@"2"]){
                        
                        // 考试无效
                        self.kwindowView.alpha = 0.3;
                        self.overTestAlertView = [HomeQuestionOverTestAlertView new];
                        self.overTestAlertView.frame = CGRectMake(ALIGN_WIDTH_PT(27.5), (SCREEN_HEIGHT - ALIGN_HEIGHT_PT(220)) / 2, SCREEN_WIDTH - ALIGN_WIDTH_PT(55), ALIGN_HEIGHT_PT(220));
                        self.overTestAlertView.backgroundColor = COLOR_RGB(225, 240, 255);
                        self.overTestAlertView.layer.cornerRadius = 10;
                        self.overTestAlertView.layer.masksToBounds = YES;
                        __weak __typeof(self)weakSelf = self;
                        self.overTestAlertView.dissmissBlock = ^{
                            weakSelf.kwindowView.alpha = 0;
                            [weakSelf.overTestAlertView removeFromSuperview];
                        };

                        self.overTestAlertView.knowBlock = ^{
                            weakSelf.kwindowView.alpha = 0;
                            [weakSelf.overTestAlertView removeFromSuperview];
                        };

                        self.overTestAlertView.lookBlock = ^{

                            weakSelf.kwindowView.alpha = 0;
                            [weakSelf.overTestAlertView removeFromSuperview];
                            HomeQuestionCompleteInfoViewController * vc = [HomeQuestionCompleteInfoViewController new];
                            vc.examId = weakSelf.examId;
                            [[SaViewControllerUtils currentViewController].navigationController pushViewController:vc animated:YES];

                        };

                        [kWindow addSubview:self.overTestAlertView];
                  
                    }else if ([str isEqualToString:@"3"]){
                    HomeQuestionTestingSubmintModel * submintModel = [HomeQuestionTestingSubmintModel mj_objectWithKeyValues:responseObject[@"data"][@"record"]];
                    // 强制交卷
                    self.kwindowView.alpha = 0.3;
                    self.QZEndAlertView = [HomeQuestionCompulsoryEndTestAlertView new];
                    self.QZEndAlertView.model = submintModel;
                    self.QZEndAlertView.frame = CGRectMake(ALIGN_WIDTH_PT(27.5), (SCREEN_HEIGHT - ALIGN_HEIGHT_PT(360)) / 2, SCREEN_WIDTH - ALIGN_WIDTH_PT(55), ALIGN_HEIGHT_PT(360));
                    self.QZEndAlertView.backgroundColor = COLOR_RGB(225, 240, 255);
                    self.QZEndAlertView.layer.cornerRadius = 10;
                    self.QZEndAlertView.layer.masksToBounds = YES;
                    __weak __typeof(self)weakSelf = self;
                    self.QZEndAlertView.dissmissBlock = ^{
                        weakSelf.kwindowView.alpha = 0;
                        [weakSelf.QZEndAlertView removeFromSuperview];
                    };

                    self.QZEndAlertView.knowBlock = ^{
                        weakSelf.kwindowView.alpha = 0;
                        [weakSelf.QZEndAlertView removeFromSuperview];
                    };

                    self.QZEndAlertView.lookBlock = ^{

                        weakSelf.kwindowView.alpha = 0;
                        [weakSelf.QZEndAlertView removeFromSuperview];
                        HomeQuestionCompleteInfoViewController * vc = [HomeQuestionCompleteInfoViewController new];
                        vc.examId = weakSelf.examId;
                        [[SaViewControllerUtils currentViewController].navigationController pushViewController:vc animated:YES];

                    };

                    [kWindow addSubview:self.QZEndAlertView];
                        
                    }
                    
                    
                }else{
                    [LUtilityTools showAlertWithTitle:@"温馨提示" message:responseObject[@"msg"] buttonAction:nil];
                    return;
                }
            }];
            
        }
        
    }
    
}

-(void)upAnswer{
    
            self.Index ++;
            NSIndexPath * indexPath = [NSIndexPath indexPathForItem:self.Index - 1 inSection:0];
            [self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:(UICollectionViewScrollPositionRight) animated:YES];
            
            if (self.Index >= self.totalNum){
                self.nextBtn.hidden = NO;
                self.upBtn.hidden = NO;
                [self.nextBtn setTitle:@"结束练习" forState:(UIControlStateNormal)];
            
            [self.upBtn mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.overBtn.mas_right).with.offset(ALIGN_WIDTH_PT(10));
                make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - ALIGN_WIDTH_PT(104)) / 2, ALIGN_HEIGHT_PT(44))));
            }];
            
            [self.nextBtn mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.bottomView).with.offset(-ALIGN_WIDTH_PT(12));
                make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - ALIGN_WIDTH_PT(104)) / 2, ALIGN_HEIGHT_PT(44))));
            }];

            
        }else{
            
            self.nextBtn.hidden = NO;
            self.upBtn.hidden = NO;
            [self.nextBtn setTitle:@"下一题" forState:(UIControlStateNormal)];
            [self.upBtn mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.overBtn.mas_right).with.offset(ALIGN_WIDTH_PT(10));
                make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - ALIGN_WIDTH_PT(104)) / 2, ALIGN_HEIGHT_PT(44))));
            }];

            [self.nextBtn mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.bottomView).with.offset(-ALIGN_WIDTH_PT(12));
                make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - ALIGN_WIDTH_PT(104)) / 2, ALIGN_HEIGHT_PT(44))));
            }];
            
        }

        self.ansowerLabel.text = [NSString stringWithFormat:@"答题进度%@/%@",@(self.Index),@(self.totalNum)];
        float percentage = (float)self.Index / self.totalNum ;
        self.sliderProgress.progress = percentage;

}

// 交卷
-(void)subMit{
    NSDictionary * paramer = @{@"examId":self.examId
    };
    [self.submitManager dispatchTaskWithParam:paramer completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
        if (responseObject && [responseObject[@"code"] intValue] == 200){

            HomeQuestionTestingSubmintModel * submintModel = [HomeQuestionTestingSubmintModel mj_objectWithKeyValues:responseObject[@"data"]];
            
            self.kwindowView.alpha = 0.3;
            self.resultAlertView = [HomeQuestionResultAlertView new];
            self.resultAlertView.model = submintModel;
            self.resultAlertView.frame = CGRectMake(ALIGN_WIDTH_PT(27.5), (SCREEN_HEIGHT - ALIGN_HEIGHT_PT(330)) / 2, SCREEN_WIDTH - ALIGN_WIDTH_PT(55), ALIGN_HEIGHT_PT(330));
            self.resultAlertView.backgroundColor = COLOR_RGB(225, 240, 255);
            self.resultAlertView.layer.cornerRadius = 10;
            self.resultAlertView.layer.masksToBounds = YES;
            __weak __typeof(self)weakSelf = self;
            self.resultAlertView.dissmissBlock = ^{
                weakSelf.kwindowView.alpha = 0;
                [weakSelf.resultAlertView removeFromSuperview];
            };

            self.resultAlertView.knowBlock = ^{
                weakSelf.kwindowView.alpha = 0;
                [weakSelf.resultAlertView removeFromSuperview];
            };
            
            self.resultAlertView.lookBlock = ^{
                
                weakSelf.kwindowView.alpha = 0;
                [weakSelf.resultAlertView removeFromSuperview];
                HomeQuestionCompleteInfoViewController * vc = [HomeQuestionCompleteInfoViewController new];
                vc.examId = weakSelf.examId;
                [[SaViewControllerUtils currentViewController].navigationController pushViewController:vc animated:YES];
                
                
            };
            
            [kWindow addSubview:self.resultAlertView];
            
            
        }else{
            [LUtilityTools showAlertWithTitle:@"温馨提示" message:responseObject[@"msg"] buttonAction:nil];
            return;
        }
    }];
    
    
    
}





#pragma mark -- UICollectionViewDelegate,UICollectionViewDataSource
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return [self.dataSource count];
}
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    HomeQuestionCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeQuestionCollectionViewCell" forIndexPath:indexPath];
    HomeQuestionModel * model = self.dataSource[indexPath.row];
    cell.model = model;
    
    return cell;
    
}


-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

    
}
 /* 头部视图 */
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
    UICollectionReusableView * reusableView = nil;

    
    return  reusableView;
}

/* 头部试图高度 */
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(nonnull UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
    if (section != 0) return CGSizeMake(SCREEN_WIDTH, ALIGN_HEIGHT_PT(40));
    return CGSizeMake(0, 0);
}



#pragma mark - item宽高
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
   
    return CGSizeMake(SCREEN_WIDTH, ALIGN_HEIGHT_PT(350));

    
}

#pragma mark - <UICollectionViewDelegateFlowLayout>
#pragma mark - X间距
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return  ALIGN_WIDTH_PT(0);
}
#pragma mark - Y间距
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return  ALIGN_WIDTH_PT(0);
}




#pragma mark -- 懒加载

-(UILabel *)ansowerLabel{
    if (!_ansowerLabel){
        _ansowerLabel = [UILabel new];
        _ansowerLabel.textColor = [UIColor whiteColor];
        _ansowerLabel.font = FONT14;
        _ansowerLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _ansowerLabel;
}

-(UIProgressView *)sliderProgress{
    if (!_sliderProgress){
        _sliderProgress = [UIProgressView new];
        // 范围为0.0-1.0
        _sliderProgress.progress = 0.1;
        // 设置进度调的颜色
        _sliderProgress.progressTintColor = [UIColor whiteColor];
        _sliderProgress.trackTintColor = COLOR_RGB(74, 118, 237);
        _sliderProgress.layer.cornerRadius = 4;
        _sliderProgress.layer.masksToBounds = YES;
    }
    return _sliderProgress;
}

-(UIButton *)lookInfoBtn{
    if (!_lookInfoBtn){
        _lookInfoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_lookInfoBtn setTitle:@"查看详情" forState:(UIControlStateNormal)];
        _lookInfoBtn.backgroundColor = [UIColor whiteColor];
        _lookInfoBtn.titleLabel.font = FONT12;
        [_lookInfoBtn setTitleColor:COLOR_RGB(50, 113, 237) forState:(UIControlStateNormal)];
        _lookInfoBtn.layer.cornerRadius = 5;
        _lookInfoBtn.layer.masksToBounds = YES;
        [_lookInfoBtn addTarget:self action:@selector(respondsTo_lookInfoBtn) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _lookInfoBtn;
}

-(UICollectionView *)collectionView{
    if (!_collectionView) {
        UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
        layout.minimumLineSpacing = 0;
        layout.minimumInteritemSpacing = 0;
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.backgroundColor = [UIColor clearColor];
        _collectionView.pagingEnabled = YES; // 整页滚动
        _collectionView.scrollEnabled = NO;
        _collectionView.showsVerticalScrollIndicator = NO;
        _collectionView.showsHorizontalScrollIndicator = NO;
        //cell
        [_collectionView registerClass:[HomeQuestionCollectionViewCell class] forCellWithReuseIdentifier:@"HomeQuestionCollectionViewCell"];

    }
    return _collectionView;
}

-(UIButton *)overBtn{
    if (!_overBtn){
        _overBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_overBtn setTitle:@"结束练习" forState:(UIControlStateNormal)];
        _overBtn.titleLabel.font = FONT12;
        [_overBtn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    }
    return _overBtn;
}

-(UIButton *)upBtn{
    if (!_upBtn){
        _upBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_upBtn setTitle:@"上一题" forState:(UIControlStateNormal)];
        [_upBtn setTitleColor:COLOR_RGB(50, 113, 237) forState:(UIControlStateNormal)];
        _upBtn.titleLabel.font = FONT15;
        _upBtn.layer.cornerRadius = 22;
        _upBtn.layer.masksToBounds = YES;
        _upBtn.layer.borderColor = COLOR_RGB(50, 113, 237).CGColor;
        _upBtn.layer.borderWidth = 1;
        _upBtn.backgroundColor = [UIColor whiteColor];
        [_upBtn addTarget:self action:@selector(respondsTo_UpBtn) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _upBtn;
}

-(UIButton *)nextBtn{
    if (!_nextBtn){
        _nextBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_nextBtn setTitle:@"下一题" forState:(UIControlStateNormal)];
        [_nextBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        _nextBtn.titleLabel.font = FONT15;
        _nextBtn.layer.cornerRadius = 22;
        _nextBtn.layer.masksToBounds = YES;
        _nextBtn.backgroundColor = COLOR_RGB(50, 113, 237);
        [_nextBtn addTarget:self action:@selector(respondsTo_nextBtn) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _nextBtn;
}




-(UIView *)bottomView{
    if (!_bottomView){
        _bottomView = [UIView new];
        _bottomView.backgroundColor = [UIColor whiteColor];
    }
    return _bottomView;
}


-(NSMutableArray *)dataSource{
    if (!_dataSource){
        _dataSource = [NSMutableArray array];
    }
    return _dataSource;
}

-(HomeProcessQuestionsNetworking *)manager{
    if (!_manager){
        _manager = [HomeProcessQuestionsNetworking new];
    }
    return _manager;
}

-(HomeProcessAnswerNetWorking *)processAnwerManager{
    if (!_processAnwerManager){
        _processAnwerManager = [HomeProcessAnswerNetWorking new];
    }
    return _processAnwerManager;
}

-(HomeProcessSubmitNetWorking *)submitManager{
    if (!_submitManager){
        _submitManager = [HomeProcessSubmitNetWorking new];
    }
    return _submitManager;
}


-(HomeExamViolationCreateNetworking *)createManager{
    if (!_createManager){
        _createManager = [HomeExamViolationCreateNetworking new];
    }
    return _createManager;
}



- (void)dealloc {
    // 移除通知观察者
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}



@end
